package com.jingdianjichi.oss.config;
import com.jingdianjichi.oss.adapter.AliStorageAdapter;
import com.jingdianjichi.oss.adapter.MinioStorageAdapter;
import com.jingdianjichi.oss.adapter.StorageAdapter;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 文件存储config
 *
 * @author: ChickenWing
 * @date: 2023/10/14
 */
@Configuration
@RefreshScope
public class StorageConfig {

    @Value("${storage.service.type}")
    private String storageType;
    @Bean
    @RefreshScope
    public StorageAdapter storageService(){
        if ("ali".equals(storageType)){
            return new AliStorageAdapter();
            }else if("minio".equals(storageType)){
            return new MinioStorageAdapter();
            }
        else{
            throw new RuntimeException("未知的存储类型");

        }
    }





}